package cn.wolfcode.advice;

import cn.wolfcode.exception.LogicException;
import cn.wolfcode.util.JSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class CommonExceptionHandler {
    @ExceptionHandler(LogicException.class)
    public JSONResult LogicExceptionHandler(LogicException e) {
        e.printStackTrace();
        return JSONResult.paramError(e.getMessage());
    }

    @ExceptionHandler(RuntimeException.class)
    public JSONResult RuntimeExceptionHandler(RuntimeException e) {
        e.printStackTrace();
        return JSONResult.defaultError();
    }
}
